<?php
	include_once("conn.php");

	$tid = $_GET["tid"];		//置顶贴ID
	$t_board_name = $_GET["back_board"];		//置顶贴所在版面的版名

	$sql2 = "select count(*) as zhiding_count from bbs_topic where t_state = 1 && t_session_name = '".$t_board_name."'";
	$result2 = mysql_query($sql2);
	$q_result2 = mysql_fetch_array($result2);

	$zhiding_count = $q_result2["zhiding_count"];
	$limit = 3;
	if($zhiding_count<$limit)
	{
			
		$sql = "update bbs_topic set t_state = 1 where t_id = '".$tid."'";
		$result = mysql_query($sql);
		if(!$result)
		{
			echo "<script>alert('置顶失败');window.location='browse.php?board=".$t_board_name."&tid=".$tid."';</script>";
		}
		else 
		{
			echo "<script>window.location='browse.php?board=".$t_board_name."&tid=".$tid."';</script>";	
		}	

	}
	else {
		echo "<script>alert('最多仅能放置".$limit."个置顶贴');window.location='browse.php?board=".$t_board_name."&tid=".$tid."';</script>";
	}
	
?>
<html>
<head>
<meta charset="UTF-8;" />
</head>
</html>